--[[
CastYeller2 - Announce important spell events.

Copyright (C) 2009 Adirelle

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--]]

if not CastYeller2 then return end
local CastYeller2 = CastYeller2 
local L = CastYeller2.L

local mod, super = CastYeller2:NewSinkModule('LibSink', 'LibSink-2.0')

mod.moduleTitle = L['Visual']

local options = mod:GetSinkAce3OptionsDataTable()
options.name = mod.moduleTitle
options.disabled = nil
options.args.Channel = nil
options.args.RaidWarning = nil
options.args.Default = nil
mod.options = options

mod.announceDefaultsDB = {
	color = { 1, 1, 1, 1 },
	sticky = false,
}

mod.announceOptions = {
	color = {
		name = L['Color'],
		type = 'color',
		hasAlpha = false,
	},
	sticky = {
		name = L['Sticky'],
		type = 'toggle',
	},
}

function mod:OnRegister()
	self.db = self.core.db:RegisterNamespace("Sink_LibSink", { profile = { sink20OutputSink = "None" } })
	self:SetSinkStorage(self.db.profile)
end

function mod:Sink(announce, info)
	local message = info.message:gsub('{.+}', '')
	local icon = select(3, GetSpellInfo(info.spellId or info.spell or 0))
	local r, g, b = unpack(announce.color)
	self:Pour(message, r or 1, g or 1, b or 1, nil, nil, nil, announce.sticky, _, icon)
end
